package com.yugao.fintech.draper.admin.controller;

import com.yugao.fintech.draper.admin.service.SocialUserService;
import com.yugao.fintech.draper.auth.dto.SocialUserDTO;
import com.yugao.fintech.draper.core.model.ResultVO;
import com.yugao.fintech.draper.security.annotation.SecurityInner;
import com.yugao.fintech.draper.auth.dto.UserInfoVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/gitee")
@RequiredArgsConstructor
@Tag(name = "码云Gitee用户表")
public class UsersGiteeController {

	private final SocialUserService socialUserService;

	@SecurityInner(inner = true)
	@Operation(summary = "添加")
	@PostMapping(value = "/add")
	public ResultVO<Boolean> add(@RequestBody SocialUserDTO socialUserDTO) {
		return ResultVO.success(socialUserService.addSysUsersGitee(socialUserDTO));
	}

	@SecurityInner(inner = true)
	@Operation(summary = "绑定")
	@PostMapping(value = "/binding")
	public ResultVO<Boolean> binding(@RequestBody SocialUserDTO socialUserDTO) {
		return ResultVO.success(socialUserService.binding(socialUserDTO));
	}

	@SecurityInner(inner = true)
	@Operation(summary = "更新")
	@PostMapping(value = "/update")
	public ResultVO<Boolean> update(@RequestBody SocialUserDTO socialUserDTO) {
		return ResultVO.success(socialUserService.update(socialUserDTO));
	}

	@SecurityInner(inner = true)
	@Operation(summary = "获取单条")
	@GetMapping(value = "/getByAppidAndId")
    ResultVO<SocialUserDTO> getByAppidAndId(@RequestParam("appId") String appId, @RequestParam("id") Integer id) {
		return ResultVO.success(socialUserService.getByAppidAndId(appId, id));
	}

	@SecurityInner(inner = true)
	@Operation(summary = "获取用户")
	@GetMapping(value = "/getUser")
    ResultVO<UserInfoVO> getUser(@RequestParam("appId") String appId, @RequestParam("id") Integer id) {
		return ResultVO.success(socialUserService.getUser(appId, id));
	}
}